package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.HlsDocumentType;
import com.bestow.basic.service.IHlsDocumentTypeService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 租赁单据类型Controller
 * 
 * @author liliu
 * @date 2022-09-02
 */
@RestController
@RequestMapping("/basic/documentType")
public class HlsDocumentTypeController extends BaseController
{
    @Autowired
    private IHlsDocumentTypeService hlsDocumentTypeService;

    /**
     * 查询租赁单据类型列表
     */
    @PreAuthorize("@ss.hasPermi('basic:documentType:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlsDocumentType hlsDocumentType)
    {
        startPage();
        List<HlsDocumentType> list = hlsDocumentTypeService.selectHlsDocumentTypeList(hlsDocumentType);
        return getDataTable(list);
    }

    /**
     * 导出租赁单据类型列表
     */
    @PreAuthorize("@ss.hasPermi('basic:documentType:export')")
    @Log(title = "租赁单据类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlsDocumentType hlsDocumentType)
    {
        List<HlsDocumentType> list = hlsDocumentTypeService.selectHlsDocumentTypeList(hlsDocumentType);
        ExcelUtil<HlsDocumentType> util = new ExcelUtil<HlsDocumentType>(HlsDocumentType.class);
        util.exportExcel(response, list, "租赁单据类型数据");
    }

    /**
     * 获取租赁单据类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:documentType:query')")
    @GetMapping(value = "/{documentType}")
    public AjaxResult getInfo(@PathVariable("documentType") String documentType)
    {
        return AjaxResult.success(hlsDocumentTypeService.selectHlsDocumentTypeByDocumentType(documentType));
    }

    /**
     * 新增租赁单据类型
     */
    @PreAuthorize("@ss.hasPermi('basic:documentType:add')")
    @Log(title = "租赁单据类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlsDocumentType hlsDocumentType)
    {
        return toAjax(hlsDocumentTypeService.insertHlsDocumentType(hlsDocumentType));
    }

    /**
     * 修改租赁单据类型
     */
    @PreAuthorize("@ss.hasPermi('basic:documentType:edit')")
    @Log(title = "租赁单据类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlsDocumentType hlsDocumentType)
    {
        return toAjax(hlsDocumentTypeService.updateHlsDocumentType(hlsDocumentType));
    }

    /**
     * 删除租赁单据类型
     */
    @PreAuthorize("@ss.hasPermi('basic:documentType:remove')")
    @Log(title = "租赁单据类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{documentTypes}")
    public AjaxResult remove(@PathVariable String[] documentTypes)
    {
        return toAjax(hlsDocumentTypeService.deleteHlsDocumentTypeByDocumentTypes(documentTypes));
    }
}
